package cc.rengu.igas.opms.common.util;

import cc.rengu.igas.opms.common.constant.OpmsParamConstant;
import cc.rengu.igas.opms.common.enums.RespCodeEnum;
import cc.rengu.oltp.service.common.entity.BinInfo;
import cc.rengu.oltp.service.common.entity.SysParam;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.realize.SysParamService;
import cc.rengu.oltp.service.realize.impl.SysParamServiceImpl;
import cc.rengu.oltp.utility.util.StringUtil;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

public class CardBinUtil {

    /**
     * 据交易类型 过滤签约卡bin
     *
     * @param instId
     * @param transType
     * @param cardBinInfo
     * @param transType
     * @throws Exception
     */
    public void checkDebitCardBinInfo(String instId, String transType, BinInfo cardBinInfo) throws Exception {
        RgLogger rglog = RgLog.getLogger(this.getClass().getName());
        /* 查询系统参数 */
        SysParamService sysParamService = new SysParamServiceImpl();
        SysParam sysParam = sysParamService.getSysParamInfo(instId, OpmsParamConstant.OPMS_PARAM_TYPE, transType);
        if (null != sysParam && !StringUtil.isEmptyOrNull(sysParam.getParamValue()) && !sysParam.getParamValue().contains(cardBinInfo.getBinNo())) {
            rglog.error("暂不支持该卡签约");
            throw new BizException(RespCodeEnum.NOT_SURP_ACCTTYPE_ERROR.getRespCode(), RespCodeEnum.NOT_SURP_ACCTTYPE_ERROR.getRespDesc());
        }
    }
}
